<template>
  <div class="add-card">
    <header class="add-header">
      <el-page-header content="查看详情" @back="$router.back()" />
    </header>
    <main class="add-main">
      <div class="form-container">
        <div class="title">车辆信息</div>
        <div class="form">
          <el-form ref="form" :model="form">
            <el-form-item label="车主姓名:">
              <span>{{ form.personName }}</span>
            </el-form-item>
            <el-form-item label="联系方式:">
              <span>{{ form.phoneNumber }}</span>
            </el-form-item>
            <el-form-item label="车辆号码:">
              <span>{{ form.carNumber }}</span>
            </el-form-item>
            <el-form-item label="车辆品牌:">
              <span>{{ form.carBrand }}</span>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div class="form-container">
        <div class="title">月卡缴费记录</div>
        <el-table :data="paymentRecords" style="width: 100%">
          <el-table-column type="index" label="序号" width="100" />
          <el-table-column prop="cardEndDate" label="有效时间" width="350" />
          <el-table-column prop="paymentAmount" label="支付金额" width="250" />
          <el-table-column label="支付方式" width="120">
            <template #default="{ row }">
              {{ row.paymentMethod === 'WeChat' ? '微信' : row.paymentMethod === 'Alipay' ? '支付宝' : '现金' }}
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="办理时间" width="350" />
          <el-table-column prop="createUser" label="办理人" width="120" />
        </el-table>
      </div>
    </main>
  </div>
</template>

<script>
import { getCardAPI } from '@/api/card'
export default {
  data() {
    return {
      form: {
        // 车主姓名
        personName: '',
        // 联系方式
        phoneNumber: '',
        // 车辆号码
        carNumber: '',
        // 车辆品牌
        carBrand: ''
      },
      // 月卡缴费记录
      paymentRecords: [
        {
          // 序号
          rechargeId: '',
          // 有效时间
          cardEndDate: '',
          // 支付金额
          paymentAmount: '',
          // 支付方式
          paymentMethod: '',
          // 办理时间
          createTime: '',
          // 办理人
          createUser: ''
        }
      ]
    }
  },
  created() {
    this.getCardAPI1()
  },
  methods: {
    // 获取月卡信息
    async getCardAPI1() {
      const id = this.$route.query.id
      const res = await getCardAPI(id)
      // console.log(res)
      this.form = res.data
      this.paymentRecords = res.data.rechargeList
    }
  }
}
</script>

<style scoped lang="scss">
.custom-input {
  /* 禁用默认边框 */
  border: none;
  /* 修改背景颜色 */
  background-color: transparent;
  /* 修改字体颜色 */
  color: #606266;
}
.add-card {
  background-color: #f4f6f8;
  height: 100vh;

  .add-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;

    .left {
      span {
        margin-right: 4px;
      }
      .arrow {
        cursor: pointer;
      }
    }

    .right {
      text-align: right;
    }
  }

  .add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;
      margin-bottom: 20px;
      border-radius: 4px;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);

      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
        font-size: 16px;
        font-weight: bold;
        border-bottom: 1px solid #ebeef5;
      }

      .form {
        padding: 20px;

        .el-form {
          display: flex;
          flex-wrap: wrap;

          .el-form-item {
            width: 50%;
            margin-bottom: 20px;

            .el-input {
              width: 80%;
            }
          }
        }
      }
    }

    .el-table {
      margin-top: 20px;
    }
  }
}
</style>
